<!DOCTYPE html>
<html>
  <head>
    <title>Listing 13.11</title>
    <meta charset="utf-8">
    <script type="text/javascript" src="../scripts/assert.js"></script>
    <link href="../styles/assert.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <script type="text/javascript">

      function isEventSupported(eventName) {

        var element = document.createElement('div'),          //#1
            isSupported;

        eventName = 'on' + eventName;                         //#2
        isSupported = (eventName in element);                 //#2

        if (!isSupported) {                                   //#3
          element.setAttribute(eventName, 'return;');
          isSupported = typeof element[eventName] == 'function';
        }

        element = null;                                        //#4

        return isSupported;
      }

    </script>
  </body>
</html>

